View Javadoc
1 package net.sourceforge.selfesteem; 2 3 import java.util.Iterator; 4 5 public class RootNode extends CompositeNode { 6 public RootNode() { 7 super("root"); 8 } 9 10 public String toString() { 11 Metrics metrics = new Metrics(); 12 visit(this, metrics); 13 return "Acceptance Tests : " + metrics; 14 } 15 16 private void visit(Node node, Metrics metrics) { 17 if (node instanceof TestNode) { 18 metrics.consider((TestNode) node); 19 } else if (node instanceof StoryNode) { 20 metrics.consider((StoryNode) node); 21 } 22 23 if (node instanceof CompositeNode) { 24 for (Iterator i = ((CompositeNode) node).iterator(); i.hasNext();) { 25 visit((Node) i.next(), metrics); 26 } 27 } 28 } 29 30 private static class Metrics { 31 private int _passingTests; 32 private int _tests; 33 private int _passingStories; 34 private int _stories; 35 36 void consider(TestNode node) { 37 _tests++; 38 if (node.isPassing()) _passingTests++; 39 } 40 41 void consider(StoryNode node) { 42 _stories++; 43 if (node.isPassing()) _passingStories++; 44 } 45 46 public String toString() { 47 return _passingStories + " of " + _stories + " stories complete - " + 48 _passingTests + " of " + _tests + " tests passing - " + 49 (_stories != 0 ? _passingStories * 100 / _stories : 0) + "%"; 50 } 51 } 52 }

This page was automatically generated by Maven